<?php

namespace App\Http\Controllers;

use App\Models\Category;
use App\Models\Link;
use App\Models\Topic;
use App\Models\User;
use Illuminate\Http\Request;

class CategoriesController extends Controller
{
    //
    public function show(Category $category,Topic $topic,Request $request,User $user,Link $link)
    {
        $topics = $topic::query()
            ->withOrder($request->order)
            ->with('category','user') ->where('category_id', $category->id)->paginate();
        // 活跃用户列表
        $active_users = $user->getActiveUsers();
        $links = $link->getAllCached();
        return view('topics.index', compact('topics', 'category','active_users','links'));
    }

}
